package com.fone.player.util;

import com.fone.player.client.Request;
import com.fone.player.entity.RedirectInfo;
import com.fone.player.online.activity.SubjectActivity;
import com.fone.player.online.activity.WebActivity;
import com.fone.player.play.PlayerAction;
import com.fone.player.play.PlayerFrom;
import com.fone.player.play.WebPlayerFrom;
import com.fone.player.play.WebViewPlayerActivity;

import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class Activity2poster {
	/** 日志标签 */
	private static final String TAG = "Activity2poster";

	/**
	 * 全屏播放及详情播放跳转
	 */
	// public static void startActivity(Context context, int utp, String vgurl,
	// String xyzplayurl, String dnfs, String name){
	// startActivity(context, utp, "", vgurl, xyzplayurl, dnfs, name, "", "",
	// "");
	// }

	/**
	 * 专题页及Web页跳转
	 */
	// public static void startActivity(Context context, int utp, String url,
	// String name){
	// startActivity(context, utp, url, "", "", "", name, "", "", "");
	// }

	/**
	 * 原网页及H5页面跳转
	 */
	// public static void startActivity(Context context, int utp, String ourl,
	// String btnply, String pic, String name){
	// startActivity(context, utp, "", "", "", "", name, ourl, btnply, pic);
	// }

	/**
	 * 链接地址限定 0 播放地址 访问播放接口 1 详情页地址 访问详情页接口 2 搜索地址 访问搜索接口 5 菜单地址，访问栏目接口 6
	 * 文字链接地址，打开浏览器 7 剧集列表也地址，访问剧集接口 8 打开原始网页 9 计费详情页 10 打开 h5
	 */

	public static void startActivity(Context context, RedirectInfo info) {

		Intent intent = null;
		switch (info.utp) {
		// 全屏播放
		case 0:
			FoneUtil.openOnlineVideo(context, PlayerFrom.MAIN_RELEATED, PlayerAction.FULLPLAY, null, info.xyzplayurl, info.dnfs, info.name);
			break;

		// 详情页播放
		case 1:
			FoneUtil.openOnlineVideo(context, PlayerFrom.MAIN_RELEATED, PlayerAction.DETAIL, info.vgurl, null, info.dnfs, info.name);
			break;

		// 栏目页
		case 5:
			intent = new Intent(context, SubjectActivity.class);
			intent.putExtra("url", info.url);
			intent.putExtra("name", info.name);
			intent.putExtra("weibo", info.weibourl);
			context.startActivity(intent);
			break;

		// Web页
		case 6:
			intent = new Intent(context, WebActivity.class);
			String webUrl = FoneUtil.getAbsoluteUrl(info.host, "", info.url, Request.getInstance().getCipher());
			intent.putExtra("url", webUrl);
			// intent.putExtra("url", info.url);
			intent.putExtra("name", info.name);
			intent.putExtra("weibo", info.weibourl);
			context.startActivity(intent);
			break;

		// 打开原网页
		case 8:
			// intent = new Intent(context, WebViewPlayerActivity.class);
			// intent.putExtra("xyzplay", info.xyzplayurl);
			// intent.putExtra("from", WebPlayerFrom.COLUMN.toString());
			// intent.putExtra("ourl", info.ourl);
			// intent.putExtra("btnply", info.btnply);
			// intent.putExtra("pic", info.pic);
			// intent.putExtra("name", info.name);
			// intent.putExtra("weibourl", info.weibourl);
			// context.startActivity(intent);

			FoneUtil.open3rdPlayer(context, WebPlayerFrom.COLUMN, info.ourl, info.xyzplayurl, info.name, Integer.parseInt(info.btnply), info.weibourl, info.pic);
			break;

		// 打开H5
		case 10:

			intent = new Intent(context, WebActivity.class);
			String h5Url = FoneUtil.getAbsoluteUrl(info.host, "", info.url, Request.getInstance().getCipher());
			intent.putExtra("url", h5Url);
			intent.putExtra("name", info.name);
			intent.putExtra("weibo", info.weibourl);
			context.startActivity(intent);
			break;

		default:
			break;
		}

	}

	public static void startActivity(Context context, RedirectInfo info, int comefrom) {

		Intent intent = null;
		Log.i("PostersAdapter", "PostersAdapter startActivity info.utp " + info.utp + "comeform" + comefrom);

		switch (info.utp) {

		// 全屏播放
		case 0:
			FoneUtil.openOnlineVideo(context, comefrom, PlayerAction.FULLPLAY, null, info.xyzplayurl, info.dnfs, info.name);
			break;

		// 详情页播放
		case 1:
			FoneUtil.openOnlineVideo(context, comefrom, PlayerAction.DETAIL, info.vgurl, null, info.dnfs, info.name);
			break;

		// 栏目页
		case 5:
			intent = new Intent(context, SubjectActivity.class);
			intent.putExtra("url", info.url);
			intent.putExtra("name", info.name);
			intent.putExtra("weibo", info.weibourl);
			context.startActivity(intent);
			break;

		// Web页
		case 6:
			intent = new Intent(context, WebActivity.class);
			String webUrl = FoneUtil.getAbsoluteUrl(info.host, "", info.url, Request.getInstance().getCipher());
			intent.putExtra("url", webUrl);
			// intent.putExtra("url", info.url);
			intent.putExtra("name", info.name);
			intent.putExtra("weibo", info.weibourl);
			context.startActivity(intent);
			break;

		// 打开原网页
		case 8:
			intent = new Intent(context, WebViewPlayerActivity.class);
			intent.putExtra("xyzplay", info.xyzplayurl);
			intent.putExtra("from", WebPlayerFrom.COLUMN.toString());
			intent.putExtra("ourl", info.ourl);
			intent.putExtra("btnply", info.btnply);
			intent.putExtra("pic", info.pic);
			intent.putExtra("name", info.name);
			intent.putExtra("weibourl", info.weibourl);
			context.startActivity(intent);
			break;

		// 打开H5
		case 10:

			intent = new Intent(context, WebActivity.class);
			String h5Url = FoneUtil.getAbsoluteUrl(info.host, "", info.url, Request.getInstance().getCipher());
			intent.putExtra("url", h5Url);
			intent.putExtra("name", info.name);
			intent.putExtra("weibo", info.weibourl);
			context.startActivity(intent);
			break;

		default:
			break;
		}

	}

	// public static void startActivity(Context context, int utp, String url,
	// String weiboUrl,
	// String vgurl, String xyzplayurl, String dnfs, String name,
	// String ourl, String btnply, String pic){
	// // int type = Integer.parseInt(utp);
	//
	// L.v(TAG, "startActivity","-utp-"+utp+"- name -"+name);
	// Intent intent;
	// switch (utp) {
	//
	// //全屏播放
	// case 0:
	// FoneUtil.openOnlineVideo(context, PlayerFrom.COLUMN,
	// PlayerAction.FULLPLAY, null, xyzplayurl, dnfs, name);
	// break;
	//
	// //详情页播放
	// case 1:
	// FoneUtil.openOnlineVideo(context, PlayerFrom.COLUMN, PlayerAction.DETAIL,
	// vgurl, null, dnfs, name);
	// break;
	//
	// //栏目页
	// case 5:
	// intent = new Intent(context, SubjectActivity.class);
	// intent.putExtra("url", url);
	// intent.putExtra("name", name);
	// context.startActivity(intent);
	// break;
	//
	// //Web页
	// case 6:
	// intent = new Intent(context, WebActivity.class);
	// intent.putExtra("url", url);
	// intent.putExtra("name", name);
	// context.startActivity(intent);
	// break;
	//
	// //打开原网页
	// case 8:
	//
	// //打开H5
	// case 10:
	// intent = new Intent(context, WebViewPlayerActivity.class);
	// intent.putExtra("xyzplay", xyzplayurl);
	// intent.putExtra("from", WebPlayerFrom.COLUMN.toString());
	// intent.putExtra("ourl", ourl);
	// intent.putExtra("btnply", btnply);
	// intent.putExtra("pic", pic);
	// intent.putExtra("name", name);
	// intent.putExtra("weibourl", info.weibourl);
	// context.startActivity(intent);
	// break;
	//
	// default:
	// break;
	// }
	// }
}
